home *** CD-ROM | disk | FTP | other *** search
- /*
- File: UAppleEvents.h
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __UAPPLEEVENTS__
- #define __UAPPLEEVENTS__
-
- #ifndef __APPLEEVENTS__
- #include "AppleEvents.h"
- #endif
-
- #ifndef __DATAITEM__
- #include "DataItem.h"
- #endif
-
- #ifndef __DIRECTOBJECT__
- #include "DirectObject.h"
- #endif
-
- #ifndef __EDITIONS__
- #include "Editions.h"
- #endif
-
- /***********************************|****************************************/
-
- #pragma push
- #pragma segment AppleEvent
-
- class TAddressDescription;
-
- /***********************************|****************************************/
-
- class TObjectList;
-
- class TAppleEvent : public TDirectObject
- {
- public: TAppleEvent(const AEEventClass itsEventClass, const AEEventID itsEventID, const AEAddressDesc& itsAddress, long itsSendingMode);
- TAppleEvent(const AppleEvent& theMessage, Boolean freeMessage = false );
-
- virtual ~TAppleEvent();
-
- virtual TAppleEvent* Send(OSErr& err);
-
- virtual OSErr SetAddress(const AEAddressDesc& theAddress);
- virtual void SetPriority(short thePriority);
- virtual OSErr SetReturnID(long returnID);
- virtual void SetSendingMode(long sendingMode);
- virtual void SetTimeoutVal(long theTimeoutVal);
- virtual OSErr SetTransactionID(long transactionID);
-
- virtual OSErr GetAddress(AEAddressDesc& theAddress);
- virtual short GetPriority();
- virtual OSErr GetReturnID(long& returnID);
- virtual long GetSendingMode();
- virtual long GetTimeoutVal();
- virtual OSErr GetTransactionID(long& transactionID);
-
- virtual OSErr ReadShort(const AEKeyword theKey, short& theValue);
- virtual OSErr ReadLong(const AEKeyword theKey, long& theValue);
- virtual OSErr ReadString(const AEKeyword theKey, char* theData);
- virtual OSErr ReadList(const AEKeyword theKey, const DescType theType, TObjectList& list );
- virtual OSErr ReadParameter(const AEKeyword theKey, const DescType desiredType, TAddressDescription& theData);
-
- virtual OSErr ReadParameter ( const AEKeyword theKey, StringPtr str );
- virtual OSErr ReadParameter ( const AEKeyword key, ADataItem& value );
-
- virtual OSErr WriteShort(const AEKeyword theKey, short theData);
- virtual OSErr WriteLong(const AEKeyword theKey, long theData);
- virtual OSErr WriteString(const AEKeyword theKey, const char* theData);
- virtual OSErr WriteParameter(const AEKeyword theKey, const TAddressDescription& theData);
- virtual OSErr WriteParameter(const AEKeyword theKey, const DescType typeCode, const void* theData, unsigned long dataSize);
-
- virtual OSErr WriteParameter ( const AEKeyword key, const ADataItem& value );
-
- virtual OSErr DeleteParameter(const AEKeyword theKey);
-
- AppleEvent fMessage; // Created by IAppleEvent, Set from InitializeFromMessage
- long fSendingMode; // kAENoReply, kAEQueueReply, or kAEWaitReply
- short fPriority; // kAENormalPriority or kAEHighPriority
- long fTimeoutVal; // How long should we wait for a response?
- Boolean fFreeMessage; // If TRUE then free the message when freeing the object
- };
-
- /***********************************|****************************************/
-
- class TAddressDescription : public TDirectObject
- {
- public: TAddressDescription ();
- TAddressDescription ( DescType type, const void* data, unsigned long length );
- TAddressDescription ( const AEDesc&, Boolean adoptData = false );
- TAddressDescription ( const TAddressDescription& );
- virtual ~TAddressDescription ();
-
- TAddressDescription& operator = ( const TAddressDescription& );
-
- operator AEDesc* ();
- operator AEDesc& ();
-
- Boolean operator == ( const TAddressDescription& ) const;
- Boolean operator != ( const TAddressDescription& ) const;
-
- AEDesc fData;
- private: Boolean fAdoptData;
- };
-
- /***********************************|****************************************/
-
- extern void InitUAppleEvents(ProcPtr dispatcher);
- // Loads essential tables and starts up support for appleevents
-
- extern pascal OSErr AppleEventsDispatch( const AppleEvent* message, const AppleEvent* reply, long info );
- // The general dispatch function which is passed AEInit. Forwards into gApplication->DispatchAppleEvents
-
- //extern IdleProcPtr gMacAppAppleEventIdleProc;
- // the default idle proc for AESend and AEInteractWithUser. Will be automatically set
- // to CPoint to MacAppAppleEventIdleProc. Set this to NULL in your code if you don't
- // want it or call it from your own filter proc if you just want to add behavior.
-
- //extern EventFilterProcPtr gMacAppAppleEventFilterProc;
- // the default WaitReply filter proc for AESend. Initialized to NULL. CPoint it at your
- // own filter proc if you want to handle high level events while waiting to process another
-
- /***********************************|****************************************/
-
- inline TAddressDescription::operator AEDesc* () { return &fData; }
- inline TAddressDescription::operator AEDesc& () { return fData; }
- inline short TAppleEvent::GetPriority() { return fPriority; }
- inline OSErr TAppleEvent::GetAddress(AEAddressDesc& theAddress) { return AEGetAttributeDesc(&fMessage, keyAddressAttr, typeTargetID, &theAddress); }
- inline long TAppleEvent::GetSendingMode() { return fSendingMode; }
- inline long TAppleEvent::GetTimeoutVal() { return fTimeoutVal; }
- inline OSErr TAppleEvent::SetAddress(const AEAddressDesc& theAddress) { return AEPutAttributeDesc(&fMessage, keyAddressAttr, &theAddress); }
- inline void TAppleEvent::SetPriority(short thePriority) { fPriority = thePriority; }
- inline OSErr TAppleEvent::SetReturnID(long returnID) { return AEPutAttributePtr(&fMessage, keyReturnIDAttr, typeLongInteger, (Ptr) & returnID, sizeof(returnID)); }
- inline void TAppleEvent::SetSendingMode(long sendingMode) { fSendingMode = sendingMode; }
- inline void TAppleEvent::SetTimeoutVal(long theTimeoutVal) { fTimeoutVal = theTimeoutVal; }
- inline OSErr TAppleEvent::SetTransactionID(long transactionID) { return AEPutAttributePtr(&fMessage, keyTransactionIDAttr, typeLongInteger, (Ptr) & transactionID, sizeof(transactionID)); }
- inline OSErr TAppleEvent::ReadParameter(const AEKeyword theKey, const DescType desiredType, TAddressDescription& theData) { return AEGetParamDesc(&fMessage, theKey, desiredType, theData); }
- inline OSErr TAppleEvent::WriteShort(const AEKeyword theKey, short theData) { return AEPutParamPtr(&fMessage, theKey, typeShortInteger, (Ptr) & theData, sizeof(theData)); }
- inline OSErr TAppleEvent::WriteLong(const AEKeyword theKey,long theData) { return AEPutParamPtr(&fMessage, theKey, typeLongInteger, (Ptr) & theData, sizeof(theData)); }
- inline OSErr TAppleEvent::WriteString(const AEKeyword theKey,const char* theData) { return AEPutParamPtr(&fMessage, theKey, typeChar, (Ptr) theData, strlen(theData)); }
- inline OSErr TAppleEvent::WriteParameter(const AEKeyword theKey, const TAddressDescription& theData) { return AEPutParamDesc(&fMessage, theKey, ((TAddressDescription&)theData).operator AEDesc* () ); }
- inline OSErr TAppleEvent::WriteParameter(const AEKeyword theKey, const DescType typeCode, const void* theData, unsigned long dataSize) { return AEPutParamPtr(&fMessage, theKey, typeCode, (Ptr) theData, dataSize); }
- inline OSErr TAppleEvent::DeleteParameter(const AEKeyword theKey) { return AEDeleteKeyDesc(&fMessage, theKey); }
- inline OSErr TAppleEvent::WriteParameter ( const AEKeyword key, const ADataItem& value ) { return AEPutParamPtr(&fMessage, key, value.GetDataType(), (char*) value.GetPhysicalStart(), value.GetPhysicalLength() ); }
-
- /***********************************|****************************************/
-
- #pragma pop
-
- #endif // __UAPPLEEVENTS__
-
-
-
-